package com.jediflasher.game_server.data

import com.jediflasher.game_server.core.events.EventDispatcher
import com.jediflasher.game_server.events.data.world.{WorldActorDataEventType, WorldActorDataEvent}

/**
 * User: Obi
 * Date: 14.08.11
 * Time: 13:33
 */

class WorldActorData(val id:Int) extends EventDispatcher {
	
	init();

	var name: String = null;

	var x: Float = 0;

	var y: Float = 0;

	private def init() {
		//val result:ResultSet = DataBaseManager.executeQuery()
		name = "vasya";
		x = 0;
		y = 0;
	}

	def setPosition(x: Int, y: Int) {
		var positionChanged:Boolean = false;
		if(this.x != x) {
			this.x = x;
			positionChanged = true;
		}

		if(this.y != y) {
			this.y = y;
			positionChanged = true;
		}

		if (positionChanged) dispatchEvent(new WorldActorDataEvent(WorldActorDataEventType.POSITION_CHANGE));
	}
}